package com.bootdo.project.controller;
import com.bootdo.project.domain.TAgentCommission;
import com.bootdo.project.service.impl.TAgentCommissionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by xxxx on 2019/03/19.
 */
@Controller
@RequestMapping("/tAgentCommission/")
public class TAgentCommissionController {

    @Autowired
    TAgentCommissionService tAgentCommissionService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TAgentCommission>> selectAll(){
        return Result.success(tAgentCommissionService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TAgentCommission> selectByPrimaryKey(Long id){
        return Result.success(tAgentCommissionService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TAgentCommission>> selectByCondition(TAgentCommission record){
        return Result.success(tAgentCommissionService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TAgentCommission record){
        return Result.success(tAgentCommissionService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TAgentCommission record){
        return Result.success(tAgentCommissionService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TAgentCommission record){
        return Result.success(tAgentCommissionService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TAgentCommission>>> selectByPage(Page<TAgentCommission> page){
        List<TAgentCommission> list = null;
        page = page.sequentialDisplayCalculate(tAgentCommissionService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tAgentCommissionService.selectByPage(page);
        }
        Page<List<TAgentCommission>> result = new Page<List<TAgentCommission>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TAgentCommission record){
        return Result.success(tAgentCommissionService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Long id){
        return Result.success(tAgentCommissionService.deleteByPrimaryKey(id));
    }

}
